package com.gd.iot.energy.controller.datamanage;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.consts.SystemConsts;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.common.vo.PageVO;
import com.gd.iot.energy.pojo.datamanage.vo.MeterStatusPageVO;
import com.gd.iot.energy.pojo.datamanage.vo.ReadMeterPageVO;
import com.gd.iot.energy.service.datamanage.ReadMeterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据管理-抄表数据-数据抄表/用量查询
 *
 * @author kris
 * @date Created at 2020/8/13 10:50
 */
@Api(value = "数据管理-抄表数据-数据抄表/用量查询",tags = "数据管理-抄表数据-数据抄表/用量查询")
@RestController
@RequestMapping("/admin/readMeter")
public class ReadMeterController {

    @Autowired
    private ReadMeterService readMeterService;

    @ApiOperation("数据抄表/用量查询分页列表")
    @SystemLogRecordMonitor("数据抄表/用量查询分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型 0已抄回，1未抄回，2查历史", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "archivesAddress", value = "表计地址", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "beginDate", value = "查询时间 type为查历史时 开始时间", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "endDate", value = "结束时间 只有查历史用", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getReadMeterPageVO")
    public ResponseEntity<PageVO<? extends ReadMeterPageVO>> getReadMeterPageVO(
            @RequestParam(value = "type",required = true)Integer type,
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "archivesAddress",required = false)String archivesAddress,
            @RequestParam(value = "beginDate",required = true)String beginDate,
            @RequestParam(value = "endDate",required = false)String endDate,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum
    ) {

        PageVO<? extends ReadMeterPageVO> pageVO = readMeterService.getReadMeterPageVO(type,customerSerialnumber,customerName,
                archivesAddress,beginDate,endDate,areaId,pageSize,pageNum);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("导出数据抄表/用量查询列表")
    @SystemLogRecordMonitor("导出数据抄表/用量查询列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型 0已抄回，1未抄回，2查历史", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "archivesAddress", value = "表计地址", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "beginDate", value = "查询时间 type为查历史时 开始时间", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "endDate", value = "结束时间 只有查历史用", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/exportReadMeterVO")
    public void exportReadMeterVO(
            @RequestParam(value = "type",required = true)Integer type,
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "archivesAddress",required = false)String archivesAddress,
            @RequestParam(value = "beginDate",required = true)String beginDate,
            @RequestParam(value = "endDate",required = false)String endDate,
            @RequestParam(value = "areaId",required = false)Integer areaId
    ) {

        readMeterService.exportReadMeterVO(type,customerSerialnumber,customerName,
                archivesAddress,beginDate,endDate,areaId);
    }
}
